/*! ============================================================================
 * @file oop.c 
 * @Synopsis  
 * @author DongKai
 * @version 1.0
 * @date 2009年12月01日
 *  Company: Beijing Feynman Software Technology Co., Ltd.
 */

#include <stdio.h>
#include <stdlib.h>
#include "cobj_oriented.h"
#include "cobject.h"


void MEMBER_FUNC_DEFINE(Cobject, print)
{
    puts("base:print");
}

VIRTUAL_FUNC_REGBEGIN(Cobject, NOSUPER)
VIRTUAL_FUNC_REGISTER(Cobject, print)
DESTRUCTOR_REGISTER(Cobject)
VIRTUAL_FUNC_REGEND

CONSTRUCTOR_DEFINE(Cobject)
{
    printf("Cobject New %p.\n", self);
    return self;
}

CONSTRUCTOR_ARGS_DEFINE(Cobject, int a, int b)
{
    printf("Cobject New-args %p(%d, %d).\n", self, a, b);
    return self;
}

DESTRUCTOR_DEFINE(Cobject)
{
    printf("Cobject delete %p.\n", self);
}

void MEMBER_FUNC_DEFINE(Cobject, test1)
{
    puts("Cobject::test1\n");
}

void MEMBER_FUNC_DEFINE(Cobject, test2, int aa)
{
    printf("Cobject::test2, aa=%d\n", aa);
}

MEMBER_FUNC_REGBEGIN(Cobject)
MEMBER_FUNC_REGISTER(Cobject, Cobject)
MEMBER_FUNC_REGISTER(Cobject, Cobject_args)
MEMBER_FUNC_REGISTER(Cobject, test1)
MEMBER_FUNC_REGISTER(Cobject, test2)
MEMBER_FUNC_REGEND


void dump_obj(void *obj)
{
    vtable_t *prev = (*(vtable_t **)obj);
    printf("obj ptr = %p\n", obj);
    while (prev->__entry) {
        printf("base = %p.entry = %p.\n", &prev->__base, prev->__entry);
        prev = prev->__base;
    }
}


